home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-09-17 | 32.4 KB | 998 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWPPobOb.cpp
- // Release Version: $ ODF 2 $
- //
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
- //========================================================================================
-
- #ifndef FWPPOBOB_H
- #include "FWPPobOb.h"
- #endif
-
- #ifndef FWSVIEW_H
- #include "FWSView.h"
- #endif
-
- #ifndef FWFRAME_H
- #include "FWFrame.h"
- #endif
-
- #ifndef FWSTATIC_H
- #include "FWStatic.h"
- #endif
-
- #ifndef FWEDVIEW_H
- #include "FWEdView.h"
- #endif
-
- #ifndef FWSCLBAR_H
- #include "FWSclBar.h"
- #endif
-
- #ifndef FWSCROLR_H
- #include "FWScrolr.h"
- #endif
-
- #ifndef FWPOPUP_H
- #include "FWPopup.h"
- #endif
-
- #ifndef FWLISTBX_H
- #include "FWListBx.h"
- #endif
-
- #ifndef FWCLUSTR_H
- #include "FWClustr.h"
- #endif
-
- #ifndef FWTABBER_H
- #include "FWTabber.h"
- #endif
-
- #ifndef FWUNKNOW_H
- #include "FWUnknow.h"
- #endif
-
- #ifndef FWPICTSV_H
- #include "FWPictSv.h"
- #endif
-
- //========================================================================================
- // PPob data structures
- //========================================================================================
- #pragma options align=mac68k
-
- struct SPaneInfo {
- long paneID;
- short width;
- short height;
- char visible;
- char enabled;
- char bindings[4]; // SBooleanRect
- long left; // Int32
- long top; // Int32
- long userCon;
- long superView;
- };
-
- typedef struct SViewInfo {
- long imageSize[2]; // SDimension32
- long scrollPos[2]; // SPoint32
- long scrollUnit[2]; // SPoint32
- short reconcileOverhang;
- } SViewInfo;
-
- typedef struct SControlInfo {
- long valueMessage;
- long value;
- long minValue;
- long maxValue;
- } SControlInfo;
-
- typedef struct SScrollerInfo {
- short horizBarLeftIndent;
- short horizBarRightIndent;
- short vertBarTopIndent;
- short vertBarBottomIndent;
- long scrollingViewID;
- } SScrollerInfo;
-
- typedef struct {
- char hasHorizScroll;
- char hasVertScroll;
- char hasGrow;
- char hasFocusBox;
- long doubleClickMessage;
- short textTraitsID;
- short LDEFid;
- short numberOfItems;
- } SListBoxInfo;
-
- #pragma options align=reset
-
- //========================================================================================
- //
- //========================================================================================
-
- #ifdef FW_BUILD_MAC
- #pragma segment fwppob
- #endif
-
- //----------------------------------------------------------------------------------------
- // FW_CPPobView::FW_CPPobView
- //----------------------------------------------------------------------------------------
-
- FW_CPPobView::FW_CPPobView(Environment* ev, FW_CReadableStream& stream)
- {
- FW_UNUSED(ev);
- // Set superview to frame or last parent view loaded from stream
- fSuperView = FW_CPPobReader::gDefaultSuperView;
-
- // Read PPob pane data
- SPaneInfo paneInfo;
- stream.Read(&paneInfo, sizeof(SPaneInfo));
-
- fViewID = paneInfo.paneID;
-
- // ODF doesn't support 32 bit coordinates yet like PowerPlant
- if (paneInfo.left > FW_MAXINT16 || paneInfo.left < FW_MININT16 ||
- paneInfo.top > FW_MAXINT16 || paneInfo.top < FW_MININT16 ||
- paneInfo.width > FW_MAXINT16 || paneInfo.height > FW_MAXINT16)
- PPOB_WARNING("PPobReader Warning: found a view out of 16 bit space. ODF will adjust its bounds.");
- // Manual corrections. This will make it easier to spot the offending views.
- if (paneInfo.left > FW_MAXINT16)
- paneInfo.left = 0;
- if (paneInfo.left < FW_MININT16)
- paneInfo.left = 0;
- if (paneInfo.top > FW_MAXINT16)
- paneInfo.top = 0;
- if (paneInfo.top < FW_MININT16)
- paneInfo.top = 0;
- if (paneInfo.width > FW_MAXINT16)
- paneInfo.width = FW_MAXINT16 / 2;
- if (paneInfo.height > FW_MAXINT16)
- paneInfo.height = FW_MAXINT16 / 2;
-
- FW_CPoint topLeft(FW_IntToFixed(paneInfo.left), FW_IntToFixed(paneInfo.top));
- fBounds.Set(topLeft, FW_IntToFixed(paneInfo.width), FW_IntToFixed(paneInfo.height));
-
- // Bindings: PowerPlant defines only 4 flags, left, top, right, bottom
- // Width and Height are fixed unless both flags are on in each direction
- fBindings = FW_kFixedWidth + FW_kFixedHeight;
- if (paneInfo.bindings[0])
- fBindings += FW_kLeftBinding;
- if (paneInfo.bindings[1])
- fBindings += FW_kTopBinding;
- if (paneInfo.bindings[2])
- {
- fBindings += FW_kRightBinding;
- if (paneInfo.bindings[0])
- fBindings -= FW_kFixedWidth; // left and right are bound
- }
- if (paneInfo.bindings[3])
- {
- fBindings += FW_kBottomBinding;
- if (paneInfo.bindings[1])
- fBindings -= FW_kFixedHeight; // top and bottom are bound
- }
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPPobView::Create
- //----------------------------------------------------------------------------------------
- /**
- void* FW_CPPobView::Create(FW_CReadableStream& stream, long type)
- {
- FW_UNUSED(type);
- return (new FW_CPPobView(ev, stream));
- }
- **/
-
- //----------------------------------------------------------------------------------------
- // FW_CPPobView::CreateODFView
- //----------------------------------------------------------------------------------------
-
- void FW_CPPobView::CreateODFView(Environment* ev)
- {
- FW_UNUSED(ev);
- PPOB_WARNING("FW_CPPobView::CreateODFView should not be called");
- /**
- FW_CView* view = new FW_CView (ev, fSuperView, fBounds, fViewID);
- view->SetBindings(ev, fBindings);
-
- delete this; // we don't need you anymore...
- **/
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPPobSuperView::FW_CPPobSuperView
- //----------------------------------------------------------------------------------------
-
- FW_CPPobSuperView::FW_CPPobSuperView(Environment* ev, FW_CReadableStream& stream) :
- FW_CPPobView(ev, stream),
- fIsContentView(false),
- fScrollingDirection(FW_kNoScrolling)
- {
- // Read LView data
- SViewInfo viewInfo;
- stream.Read(&viewInfo, sizeof(SViewInfo));
-
- // Set the extent with the PP imageSize
- long width = viewInfo.imageSize[0];
- long height = viewInfo.imageSize[1];
-
- if (width > FW_MAXINT16 || height > FW_MAXINT16)
- PPOB_WARNING("PPobReader Warning: view imageSize is too big. ODF will adjust its extent.");
- if (width > FW_MAXINT16)
- width = FW_MAXINT16 / 2;
- if (height > FW_MAXINT16)
- height = FW_MAXINT16 / 2;
-
- fExtent.Set(FW_IntToFixed(width), FW_IntToFixed(height));
-
- // if there is a scrolling view it must become the content view
- if (FW_CPPobReader::gScroller != 0 &&
- fViewID == FW_CPPobReader::gScroller->fScrollingViewID)
- {
- // We adjust the content view use to the size and location of the scroller
- // This avoids having to adjust the LView inside the LScroller in Constructor
-
- fBounds = FW_CPPobReader::gScroller->fBounds;
-
- // Handle case when the scroller takes the whole window (left and top are -1).
- if (fBounds.left < FW_kFixed0)
- fBounds.left = FW_kFixed0;
- if (fBounds.top < FW_kFixed0)
- fBounds.top = FW_kFixed0;
-
- fBindings = FW_CPPobReader::gScroller->fBindings;
-
- // Check for horiz and vert scroll bars
- if (FW_CPPobReader::gScroller->fHorizBarLeftIndent >= 0)
- {
- fScrollingDirection = FW_EScrollingDirection(fScrollingDirection | FW_kXScrolling);
- fBounds.bottom -= FW_IntToFixed(16); // space for horizontal scrollbar
- }
- if (FW_CPPobReader::gScroller->fVertBarTopIndent >= 0)
- {
- fScrollingDirection = FW_EScrollingDirection(fScrollingDirection | FW_kYScrolling);
- fBounds.right -= FW_IntToFixed(16); // space for vertical scrollbar
- }
-
- fIsContentView = true;
- }
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPPobSuperView::Create
- //----------------------------------------------------------------------------------------
-
- void* FW_CPPobSuperView::Create(Environment*ev, FW_CReadableStream& stream, long type)
- {
- FW_UNUSED(type);
- return (new FW_CPPobSuperView(ev, stream));
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPPobSuperView::CreateODFView
- //----------------------------------------------------------------------------------------
-
- void FW_CPPobSuperView::CreateODFView(Environment* ev)
- {
- // Create the ODF superview
- FW_CSuperView* view = new FW_CSuperView(ev, fSuperView, fBounds, fViewID, fExtent,
- fScrollingDirection);
- view->SetBindings(ev, fBindings);
-
- PostCreateODFView(ev, view);
-
- delete this; // we don't need you anymore...
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPPobSuperView::PostCreateODFView
- //----------------------------------------------------------------------------------------
-
- void FW_CPPobSuperView::PostCreateODFView(Environment* ev, FW_CSuperView* view)
- {
- // Make it the default superview for nested views
- FW_CPPobReader::gDefaultSuperView = view;
-
- if (fIsContentView)
- {
- FW_ASSERT(FW_CPPobReader::gScroller != 0);
- FW_CFrame* frame = view->GetFrame(ev);
- if (frame->IsContentView(ev) == false)
- {
- PPOB_WARNING("PPobReader Warning: found more than 1 scrolling view");
- }
- else
- {
- // Declare the content view and the scroller
- view->BecomeContentView(ev);
-
- FW_CScroller* scroller = (FW_CScroller*)FW_CPPobReader::gScroller->fODFScroller;
- FW_ASSERT(scroller != 0);
- view->GetFrame(ev)->AdoptScroller(ev, scroller);
- }
- // Now we don't need our FW_CPPobScrollBarScroller object anymore
- delete FW_CPPobReader::gScroller;
- FW_CPPobReader::gScroller = 0;
- }
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPPobEditView::FW_CPPobEditView
- //----------------------------------------------------------------------------------------
- FW_DEFINE_AUTO(FW_CPPobEditView)
-
- FW_CPPobEditView::FW_CPPobEditView(Environment*ev, FW_CReadableStream& stream) :
- FW_CPPobView(ev, stream)
- {
- fText = FW_CPPobReader::ReadStr255(stream);
- stream >> fTextTraitsID >> fMaxChars >> fAttributes >> fKeyFilterID;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPPobEditView::Create
- //----------------------------------------------------------------------------------------
-
- void* FW_CPPobEditView::Create(Environment*ev, FW_CReadableStream& stream, long type)
- {
- FW_UNUSED(type);
- return FW_NEW(FW_CPPobEditView, (ev, stream));
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPPobEditView::CreateODFView
- //----------------------------------------------------------------------------------------
-
- enum { // from Powerplant's LEditField.h
- editAttr_Box = 0x80,
- editAttr_WordWrap = 0x40,
- editAttr_AutoScroll = 0x20,
- editAttr_TextBuffer = 0x10,
- editAttr_OutlineHilite = 0x08,
- editAttr_InlineInput = 0x04,
- editAttr_TextServices = 0x02
- };
-
- void FW_CPPobEditView::CreateODFView(Environment* ev)
- {
- FW_TextBoxOptions options;
- FW_CFont font;
- FW_CColor color;
- FW_CPPobReader::GetTextTraits(fTextTraitsID, font, options, color);
-
- unsigned short attributes = 0;
- if (fAttributes & editAttr_Box)
- attributes += FW_CEditView::kDrawBox;
- if (fAttributes & editAttr_WordWrap)
- attributes += FW_CEditView::kWordWrap;
- if (fAttributes & editAttr_AutoScroll)
- attributes += FW_CEditView::kAutoScroll;
- if (fAttributes & editAttr_TextBuffer)
- attributes += FW_CEditView::kTextBuffering;
- if (fAttributes & editAttr_OutlineHilite)
- attributes += FW_CEditView::kOutlineHilite;
- if (fAttributes & editAttr_InlineInput)
- attributes += FW_CEditView::kInlineInput;
- if (fAttributes & editAttr_TextServices)
- attributes += FW_CEditView::kTextServices;
-
- FW_CEditView* view = FW_NEW(FW_CEditView, (ev, fSuperView, fBounds, fViewID, fText,
- font, fMaxChars, attributes));
- view->SetBindings(ev, fBindings);
-
- delete this; // we don't need you anymore...
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPPobTextEdit::FW_CPPobTextEdit
- //----------------------------------------------------------------------------------------
- FW_DEFINE_AUTO(FW_CPPobTextEdit)
-
- FW_CPPobTextEdit::FW_CPPobTextEdit(Environment*ev, FW_CReadableStream& stream) :
- FW_CPPobSuperView(ev, stream)
- {
- ResIDT initialTextID;
-
- stream >> fAttributes >> fTextTraitsID >> initialTextID;
-
- Handle textHdl = ::GetResource('TEXT', initialTextID);
- if (textHdl)
- {
- ::HLock(textHdl);
- fText.ReplaceAll(*textHdl, ::GetHandleSize(textHdl));
- ::HUnlock(textHdl);
- ::ReleaseResource(textHdl);
- }
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPPobTextEdit::Create
- //----------------------------------------------------------------------------------------
-
- void* FW_CPPobTextEdit::Create(Environment*ev, FW_CReadableStream& stream, long type)
- {
- FW_UNUSED(type);
- return FW_NEW(FW_CPPobTextEdit, (ev, stream));
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPPobTextEdit::CreateODFView
- //----------------------------------------------------------------------------------------
-
- enum {
- textAttr_MultiStyle = 0x8000,
- textAttr_Editable = 0x4000,
- textAttr_Selectable = 0x2000,
- textAttr_WordWrap = 0x1000
- };
-
- void FW_CPPobTextEdit::CreateODFView(Environment* ev)
- {
- FW_TextBoxOptions options;
- FW_CFont font;
- FW_CColor color;
- FW_CPPobReader::GetTextTraits(fTextTraitsID, font, options, color);
-
- unsigned short attributes = FW_CEditView::kDrawBox + FW_CEditView::kAutoScroll;
- if (fAttributes & textAttr_WordWrap)
- attributes += FW_CEditView::kWordWrap;
-
- // ODF doesn't have scrolling text views yet, so we can only create an FW_CEditView
- // (see ODF Form for an example of scrolling text view mapping to LTextEdit)
-
- FW_CEditView* view = FW_NEW(FW_CEditView, (ev, fSuperView, fBounds, fViewID, fText,
- font, -1, attributes));
- view->SetBindings(ev, fBindings);
-
- // We ignore the scroller which may be containing this LTextEdit and we DON'T call
- // FW_CPPobSuperView::PostCreateODFView.
- if (FW_CPPobReader::gScroller)
- {
- delete FW_CPPobReader::gScroller->fODFScroller;
- delete FW_CPPobReader::gScroller;
- FW_CPPobReader::gScroller = 0;
- }
-
- delete this; // we don't need you anymore...
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPPobStaticText::FW_CPPobStaticText
- //----------------------------------------------------------------------------------------
- FW_DEFINE_AUTO(FW_CPPobStaticText)
-
- FW_CPPobStaticText::FW_CPPobStaticText(Environment*ev, FW_CReadableStream& stream) :
- FW_CPPobView(ev, stream)
- {
- fText = FW_CPPobReader::ReadStr255(stream);
- stream >> fTextTraitsID;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPPobStaticText::Create
- //----------------------------------------------------------------------------------------
-
- void* FW_CPPobStaticText::Create(Environment*ev, FW_CReadableStream& stream, long type)
- {
- FW_UNUSED(type);
- return FW_NEW(FW_CPPobStaticText, (ev, stream));
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPPobStaticText::CreateODFView
- //----------------------------------------------------------------------------------------
-
- void FW_CPPobStaticText::CreateODFView(Environment* ev)
- {
- FW_TextBoxOptions options;
- FW_CFont font;
- FW_CColor color;
- FW_CPPobReader::GetTextTraits(fTextTraitsID, font, options, color);
- options |= FW_kTextBoxClipToBox | FW_kTextBoxWordWrap;
- FW_CInk textInk(color, FW_kRGBWhite, FW_kOr);
-
- // [LSD] FW_CStaticText ignores the viewID for now
- FW_CStaticText* view = FW_NEW(FW_CStaticText, (ev, fSuperView, fBounds, fViewID, fText, font,
- options, textInk));
- view->SetBindings(ev, fBindings);
-
- delete this; // we don't need you anymore...
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPPobGroupBox::FW_CPPobGroupBox
- //----------------------------------------------------------------------------------------
- FW_DEFINE_AUTO(FW_CPPobGroupBox)
-
- FW_CPPobGroupBox::FW_CPPobGroupBox(Environment*ev, FW_CReadableStream& stream) :
- FW_CPPobStaticText(ev, stream)
- {
- // Same data as a StaticText
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPPobGroupBox::Create
- //----------------------------------------------------------------------------------------
-
- void* FW_CPPobGroupBox::Create(Environment*ev, FW_CReadableStream& stream, long type)
- {
- FW_UNUSED(type);
- return FW_NEW(FW_CPPobGroupBox, (ev, stream));
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPPobGroupBox::CreateODFView
- //----------------------------------------------------------------------------------------
-
- void FW_CPPobGroupBox::CreateODFView(Environment* ev)
- {
- FW_TextBoxOptions options;
- FW_CFont font;
- FW_CColor color;
- FW_CPPobReader::GetTextTraits(fTextTraitsID, font, options, color);
- options |= FW_kTextBoxClipToBox | FW_kTextBoxWordWrap;
- FW_CInk textInk(color, FW_kRGBWhite, FW_kOr);
-
- FW_CGroupBox* view = FW_NEW(FW_CGroupBox, (ev, fSuperView, fBounds, fViewID, fText, font,
- options, textInk, color));
- view->SetBindings(ev, fBindings);
-
- delete this; // we don't need you anymore...
- }
- //----------------------------------------------------------------------------------------
- // FW_CPPobControl::FW_CPPobControl
- //----------------------------------------------------------------------------------------
-
- FW_CPPobControl::FW_CPPobControl(Environment*ev, FW_CReadableStream& stream) :
- FW_CPPobView(ev, stream)
- {
- SControlInfo controlInfo;
- stream.Read(&controlInfo, sizeof(SControlInfo));
-
- fMessage = controlInfo.valueMessage;
- fValue = controlInfo.value;
- fMinValue = controlInfo.minValue;
- fMaxValue = controlInfo.maxValue;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPPobControl::Create
- //----------------------------------------------------------------------------------------
- /**
- void* FW_CPPobControl::Create(FW_CReadableStream& stream, long type)
- {
- FW_UNUSED(type);
- return (new FW_CPPobControl(ev, stream));
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPPobControl::CreateODFView
- //----------------------------------------------------------------------------------------
-
- void FW_CPPobControl::CreateODFView(Environment* ev)
- {
- FW_CControl* view = FW_NEW(FW_CControl, (ev, fSuperView, fViewID, fBounds, fMessage, fValue));
- view->SetBindings(ev, fBindings);
-
- delete this; // we don't need you anymore...
- }
- **/
-
- //----------------------------------------------------------------------------------------
- // FW_CPPobButton::FW_CPPobButton
- //----------------------------------------------------------------------------------------
- FW_DEFINE_AUTO(FW_CPPobButton)
-
- FW_CPPobButton::FW_CPPobButton(Environment* ev, FW_CReadableStream& stream) :
- FW_CPPobControl(ev, stream)
- {
- // [LSD] We read LStdControl data here instead of in FW_CNativeControl because
- // the class fields don't match. Same as in Popup menu
-
- short controlKind;
- long macRefCon;
-
- stream >> controlKind >> fTextTraitsID;
-
- fLabel = FW_CPPobReader::ReadStr255(stream);
-
- stream >> macRefCon; // not used by ODF
-
- // Translation to ODF fields
-
- if (controlKind == checkBoxProc)
- fKind = FW_kCheckButton;
- else if (controlKind == radioButProc)
- fKind = FW_kRadioButton;
- else
- fKind = FW_kPushButton;
-
- // Special case of default and cancel buttons in dialogs
-
- if (FW_CPPobReader::gDefaultButtonID != 0 &&
- FW_CPPobReader::gDefaultButtonID == fViewID)
- {
- fKind = FW_kDefaultPushButton;
- fMessage = FW_kDefaultButtonMsg;
- FW_CPPobReader::gDefaultButtonID = 0;
- }
- if (FW_CPPobReader::gCancelButtonID != 0 &&
- FW_CPPobReader::gCancelButtonID == fViewID)
- {
- fMessage = FW_kCancelButtonMsg;
- FW_CPPobReader::gCancelButtonID = 0;
- }
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPPobButton::Create
- //----------------------------------------------------------------------------------------
-
- void* FW_CPPobButton::Create(Environment*ev, FW_CReadableStream& stream, long type)
- {
- FW_UNUSED(type);
- return FW_NEW(FW_CPPobButton, (ev, stream));
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPPobButton::CreateODFView
- //----------------------------------------------------------------------------------------
-
- void FW_CPPobButton::CreateODFView(Environment* ev)
- {
- FW_TextBoxOptions options;
- FW_CFont font;
- FW_CColor color;
- FW_CPPobReader::GetTextTraits(fTextTraitsID, font, options, color);
-
- FW_CButton* view = FW_NEW(FW_CButton,
- (ev, fSuperView, fBounds, fViewID, fKind, fLabel, font, fMessage, fValue));
- view->SetBindings(ev, fBindings);
-
- delete this; // we don't need you anymore...
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPPobPopupMenu::FW_CPPobPopupMenu
- //----------------------------------------------------------------------------------------
- FW_DEFINE_AUTO(FW_CPPobPopupMenu)
-
- FW_CPPobPopupMenu::FW_CPPobPopupMenu(Environment* ev, FW_CReadableStream& stream) :
- FW_CPPobControl(ev, stream)
- {
- // [LSD] We read LStdControl data here instead of in FW_CNativeControl because
- // the class fields don't match. Same as in Button
-
- stream >> fControlKind >> fTextTraitsID;
-
- fLabel = FW_CPPobReader::ReadStr255(stream);
-
- stream >> fRefCon;
-
- stream >> fInitialItem;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPPobPopupMenu::Create
- //----------------------------------------------------------------------------------------
-
- void* FW_CPPobPopupMenu::Create(Environment*ev, FW_CReadableStream& stream, long type)
- {
- FW_UNUSED(type);
- return FW_NEW(FW_CPPobPopupMenu, (ev, stream));
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPPobPopupMenu::CreateODFView
- //----------------------------------------------------------------------------------------
-
- void FW_CPPobPopupMenu::CreateODFView(Environment* ev)
- {
- FW_TextBoxOptions options;
- FW_CFont font;
- FW_CColor color;
- FW_CPPobReader::GetTextTraits(fTextTraitsID, font, options, color);
-
- // MenuID and titleWidth were stored in the MinValue & MaxValue fields of Control
- FW_CPopupMenu* view = FW_NEW(FW_CPopupMenu, (ev, fSuperView, fBounds, fViewID,
- fMinValue, fLabel, fMaxValue, fInitialItem, 0, font, fRefCon));
- view->SetBindings(ev, fBindings);
-
- delete this; // we don't need you anymore...
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPPobScrollBarScroller::FW_CPPobScrollBarScroller
- //----------------------------------------------------------------------------------------
- // LScroller derives from LView in PowerPlant, so we must read the LView data first
-
- FW_CPPobScrollBarScroller::FW_CPPobScrollBarScroller(Environment* ev,
- FW_CReadableStream& stream, FW_Boolean liveScrolling) :
- FW_CPPobSuperView(ev, stream),
- fLiveScrolling(liveScrolling),
- fODFScroller(0)
- {
- // Keep globale around to create the content view later
- FW_CPPobReader::gScroller = this;
-
- SScrollerInfo scrollerInfo;
- stream.Read(&scrollerInfo, sizeof(SScrollerInfo));
-
- fHorizBarLeftIndent = scrollerInfo.horizBarLeftIndent;
- fHorizBarRightIndent = scrollerInfo.horizBarRightIndent;
- fVertBarTopIndent = scrollerInfo.vertBarTopIndent;
- fVertBarBottomIndent = scrollerInfo.vertBarBottomIndent;
- fScrollingViewID = scrollerInfo.scrollingViewID;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPPobScrollBarScroller::Create
- //----------------------------------------------------------------------------------------
-
- void* FW_CPPobScrollBarScroller::Create(Environment*ev, FW_CReadableStream& stream, long type)
- {
- // Even though ODF allows only 1 scroller view (the content view) we can't ignore
- // additional scrollers which may be used for custom views, like CScrollEdit in Form.
- // The important thing will be to delete it later (see CPPobScrollEdit::CreateODFView)
- /*
- FW_CFrame* frame = FW_CPPobReader::gDefaultSuperView->GetFrame(ev);
- if (frame->GetScroller(ev) != 0)
- {
- PPOB_WARNING("PPobReader Warning: This frame already has a scroller view");
- return 0;
- }
- */
- return (new FW_CPPobScrollBarScroller(ev, stream, (type == 'ascr')));
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPPobScrollBarScroller::CreateODFView
- //----------------------------------------------------------------------------------------
-
- void FW_CPPobScrollBarScroller::CreateODFView(Environment* ev)
- {
- // Create the scroll bars first
-
- FW_CSuperView* superview = FW_CPPobReader::gDefaultSuperView;
- FW_CScrollBar* horzSB = 0;
- if (fHorizBarLeftIndent >= 0)
- {
- FW_CRect bounds = fBounds;
- bounds.left += FW_IntToFixed(fHorizBarLeftIndent);
- bounds.right -= FW_IntToFixed(fHorizBarRightIndent);
- bounds.top = bounds.bottom - FW_IntToFixed(16);
-
- horzSB = FW_NEW(FW_CScrollBar, (ev, superview, bounds, 'horz'));
- }
-
- FW_CScrollBar* vertSB = 0;
- if (fVertBarTopIndent >= 0)
- {
- FW_CRect bounds = fBounds;
- bounds.top += FW_IntToFixed(fVertBarTopIndent);
- bounds.bottom -= FW_IntToFixed(fVertBarBottomIndent);
- bounds.left = bounds.right - FW_IntToFixed(16);
-
- vertSB = FW_NEW(FW_CScrollBar, (ev, superview, bounds, 'vert'));
- }
-
- // Create the ODF scroller. Keep global for AdoptScroller later.
- FW_CFrame* frame = FW_CPPobReader::gDefaultSuperView->GetFrame(ev);
- FW_CPPobReader::gScroller->fODFScroller = FW_NEW(FW_CScrollBarScroller,
- (ev, frame, fLiveScrolling, horzSB, vertSB));
-
- // Don't delete this FW_CPPobScrollBarScroller here, we do need it for the
- // creation of the content view later...
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPPobListBox::FW_CPPobListBox
- //----------------------------------------------------------------------------------------
- FW_DEFINE_AUTO(FW_CPPobListBox)
-
- FW_CPPobListBox::FW_CPPobListBox(Environment*ev, FW_CReadableStream& stream) :
- FW_CPPobView(ev, stream)
- {
- SListBoxInfo listInfo;
- stream.Read(&listInfo, sizeof(SListBoxInfo));
-
- // Horizontal SB and custom LDEF are not supported
- fNumRows = listInfo.numberOfItems;
- fScrollVert = listInfo.hasVertScroll;
- fTextTraitsID = listInfo.textTraitsID;
- fDoubleClickMsg = listInfo.doubleClickMessage;
- fSingleSelection = (listInfo.hasGrow == 0); // HACK: use Grow box for this flag...
- fUseFocusFrame = listInfo.hasFocusBox;
-
- // Read the string items.
- // [LSD] we ignore these strings for now. Anyway they cannot be entered in Constructor
- // one need a Rez or Resourcerer template
- for (int i = 0; i < fNumRows; i++)
- {
- FW_CString item = FW_CPPobReader::ReadStr255(stream);
- }
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPPobListBox::Create
- //----------------------------------------------------------------------------------------
-
- void* FW_CPPobListBox::Create(Environment*ev, FW_CReadableStream& stream, long type)
- {
- FW_UNUSED(type);
- return FW_NEW(FW_CPPobListBox, (ev, stream));
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPPobListBox::CreateODFView
- //----------------------------------------------------------------------------------------
-
- void FW_CPPobListBox::CreateODFView(Environment* ev)
- {
- FW_TextBoxOptions options;
- FW_CFont font;
- FW_CColor color;
- FW_CPPobReader::GetTextTraits(fTextTraitsID, font, options, color);
-
- // Create the ODF listbox
- FW_CListBox* view = FW_NEW(FW_CListBox, (ev, fSuperView, fBounds, fViewID, fNumRows,
- fScrollVert, font, fDoubleClickMsg, fSingleSelection, fUseFocusFrame, false));
- view->SetBindings(ev, fBindings);
-
- delete this; // we don't need you anymore...
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPPobPictSView::FW_CPPobPictSView
- //----------------------------------------------------------------------------------------
-
- FW_CPPobPictSView::FW_CPPobPictSView(Environment*ev, FW_CReadableStream& stream, long type) :
- FW_CPPobSuperView(ev, stream)
- {
- FW_UNUSED(type);
- stream >> fPictID;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPPobPictSView::Create
- //----------------------------------------------------------------------------------------
-
- void* FW_CPPobPictSView::Create(Environment*ev, FW_CReadableStream& stream, long type)
- {
- return (new FW_CPPobPictSView(ev, stream, type));
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPPobPictSView::CreateODFView
- //----------------------------------------------------------------------------------------
-
- void FW_CPPobPictSView::CreateODFView(Environment* ev)
- {
- // Load the Mac picture resource manually instead of using FW_CPicture API because
- // we don't have the resource file here
- FW_PlatformPict macPictHdl = ::GetPicture(fPictID);
- FW_CPictSView* view;
-
- if (macPictHdl)
- {
- // Must detach the resource manually because we loaded it manually
- ::DetachResource((Handle)macPictHdl);
-
- // Create the FW_CPictSView view
- view = FW_NEW(FW_CPictSView, (ev, fSuperView, fBounds, fViewID,
- FW_CPicture(macPictHdl)));
- }
- else
- {
- // If the picture cannot be loaded here we create a FW_CPictSView with the same
- // pict ID, the FW_CPictSView class will display an error message
- view = FW_NEW(FW_CPictSView, (ev, fSuperView, fBounds, fViewID, fPictID));
- }
- view->SetBindings(ev, fBindings);
-
- // Important: all superview classes must call PostCreateODFView before returning
- PostCreateODFView(ev, view);
-
- delete this; // we don't need you anymore...
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPPobUnknownView::FW_CPPobUnknownView
- //----------------------------------------------------------------------------------------
-
- FW_CPPobUnknownView::FW_CPPobUnknownView(Environment*ev, FW_CReadableStream& stream, long type) :
- FW_CPPobView(ev, stream),
- fClassID(type)
- {
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPPobUnknownView::CreateODFView
- //----------------------------------------------------------------------------------------
-
- void FW_CPPobUnknownView::CreateODFView(Environment* ev)
- {
- FW_CString className((char*)&fClassID, 4);
-
- FW_CUnknownView* view = FW_NEW(FW_CUnknownView, (ev, fSuperView, fViewID, fBounds, className));
- view->SetBindings(ev, fBindings);
-
- delete this; // we don't need you anymore...
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPPobUnknownSView::FW_CPPobUnknownSView
- //----------------------------------------------------------------------------------------
-
- FW_CPPobUnknownSView::FW_CPPobUnknownSView(Environment*ev, FW_CReadableStream& stream, long type) :
- FW_CPPobSuperView(ev, stream),
- fClassID(type)
- {
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPPobUnknownSView::CreateODFView
- //----------------------------------------------------------------------------------------
-
- void FW_CPPobUnknownSView::CreateODFView(Environment* ev)
- {
- FW_CString className((char*)&fClassID, 4);
-
- FW_CUnknownView* view = FW_NEW(FW_CUnknownView, (ev, fSuperView, fViewID, fBounds,
- fExtent, fScrollingDirection, className));
- view->SetBindings(ev, fBindings);
-
- PostCreateODFView(ev, view);
-
- delete this; // we don't need you anymore...
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPPobRadioCluster::Create
- //----------------------------------------------------------------------------------------
- // Radio groups are not views, we read the stream and create the ODF cluster directly
-
- void* FW_CPPobRadioCluster::Create(Environment*ev, FW_CReadableStream& stream, long type)
- {
- FW_UNUSED(type);
- short numRadios;
- stream >> numRadios;
-
- FW_CRadioCluster* radioCluster = FW_NEW(FW_CRadioCluster, (ev));
- FW_CSuperView* superview = FW_CPPobReader::gDefaultSuperView;
-
- for (int i = 0; i < numRadios; i++)
- {
- PaneIDT radioID;
- stream >> radioID;
-
- FW_CView* view = superview->FindViewByID(ev, radioID);
- FW_CButton* button = FW_DYNAMIC_CAST(FW_CButton, view);
- radioCluster->AddRadio(ev, button);
- }
-
- return 0; // Return null object to by-pass CreateODFView method
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPPobViewTabber::Create
- //----------------------------------------------------------------------------------------
- // Tab groups are not views, we create the ODF tabber directly
-
- void* FW_CPPobViewTabber::Create(Environment*ev, FW_CReadableStream& stream, long type)
- {
- FW_UNUSED(stream);
- FW_UNUSED(type);
- FW_CViewTabber* viewTabber = new FW_CViewTabber(ev, FW_CPPobReader::gDefaultSuperView);
-
- return 0; // Return null object to by-pass CreateODFView method
- }
-
-
-
-